<template>
    <div class="main-page">
        <div class="main" style="position:relative">
            <div class="main-info">
                <div class="main-title">活动列表</div>
                <div>
                    <el-button 
                    type="primary" 
                    class='pass-btn' 
                    @click='handlePassList'>核销
                    </el-button>
                </div>
            </div>
            <div class="select-condition">
                <el-form ref="form" :inline="true" label-width="100px">
                    <el-form-item label="建筑物：">
                        <el-select v-model="building " @change='getbuildId' placeholder="建筑物">
                        <el-option v-for='item in buildList'  :label="item.buildName" :value="item.buildIdStr" :key='item.buildName'></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="活动发布方：">
                        <el-select @change='getPoitype' v-model="poitype" placeholder="全部">
                            <el-option label="全部" value="">全部</el-option>
                            <el-option label="商场活动" value="0">商场活动</el-option>
                            <el-option label="商户活动" value="1">商户活动</el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="活动类型：">
                        <el-select @change='getType' v-model="type" placeholder="全部">
                            <el-option label="全部活动" value=""></el-option>
                            <el-option label="会员活动" value="1"></el-option>
                            <el-option label="普通活动" value="0"></el-option>
                        </el-select>
                    </el-form-item>
                    <br/>
                    <el-form-item label='创建时间：'>
                        <el-date-picker
                            v-model="createDateStart"
                            @change='getStartTime'
                            type="date"
                            placeholder="选择起始时间">
                        </el-date-picker>
                        <span style="color:#888">~</span>
                        <el-date-picker
                            v-model="createDateEnd"
                            @change='getEndTime'
                            type="date"
                            placeholder="选择结束时间">
                        </el-date-picker>
                    </el-form-item>     
                </el-form>
                <div class="check-activity-btn">
                    <el-button type="primary" class='check-btn' @click='handleCheckList'>查询 </el-button>
                    <el-button type="danger" class='check-btn' @click='handleClearList'>清空</el-button>
                </div>
            </div>
            <div class="list-data">
   
                <div class="edit">
                    <el-button 
                    class='pass-btn' 
                    @click='handleLink' 
                    v-loading.fullscreen.lock="loading" 
                    type="primary">活动创建
                    </el-button>
                </div>
                <el-tabs  
                v-model="activeName" 
                type="border-card" 
                @tab-click='handleSelectedTab'>  
                    <el-tab-pane 
                    v-loading.body="oneLoading" 
                    element-loading-text="拼命加载中" 
                    label='未发布' 
                    name='未发布'>
                        <div 
                        v-for='(item,index) in listInfo' 
                        :key='item.id' 
                        class="item-style">
                            <el-row>
                                <el-col :span="10">
                                    <div class="grid-content bg-purple base-topic">
                                    {{item.title}}
                                    </div>
                                </el-col>
                                <el-col :span="6">
                                    <div class="grid-content bg-purple-light base-topic">
                                    {{item.type == 1 ? '会员活动' : '普通活动'}}
                                    </div>
                                </el-col>
                                <el-col :span="6">
                                    <div class="grid-content bg-purple base-topic">
                                    更新日期：{{item.createDate}}
                                    </div>
                                </el-col>
                            </el-row>
                            <el-row>
                                <div class="grid-content bg-purple">
                                    <i class="iconfont icon-tubiao-"></i>
                                    {{item.poitype == 1 ? '商户活动':'商场活动'}}
                                    <span>{{item.buildName}}</span>
                                </div>
                                <div class="grid-content bg-purple">
                                    <i class="iconfont icon-dizhi1"></i>
                                    {{item.place}} 
                                </div>
                                <div class="grid-content bg-purple">
                                    <i class="iconfont">&#xe624;</i>
                                    {{item.time}} 
                                    <span class="activity-time">{{item.enrollStart}} 到 {{item.enrollEnd}}</span>
                                    <span>活动时间:{{item.startDate}} 到 {{item.endDate}}</span>
                                </div>
                            </el-row>
                            
                            <div class="advanced">
                                <div style="flex:1;text-align:center">
                                    <router-link :to="{path:'read_list/'+item.id,query:{title:item.title}}">
                                        <span class="read-num">
                                            <i class="iconfont">&#xe609;</i>
                                            {{item.readnum}}
                                        </span>
                                    </router-link>
                                    <router-link :to="{path:'good_list/'+item.id,query:{title:item.title}}">
                                    <span class="read-num">
                                        <i class="iconfont">&#xe60c;</i>
                                        {{item.goodnum}}
                                    </span>  
                                    </router-link>
                                </div>
                                <div class="activity-process">
                                
                                    <span 
                                    @click='handlePublish(index)'  
                                    v-if='item.status == 0 ? true : false'>
                                        上线
                                    </span>
                                    <router-link :to="'mod/'+item.id">
                                        <span @click='handkeEditLink' v-loading.fullscreen.lock="loading">编辑</span>
                                    </router-link>
                                    <router-link :to="'view/'+item.id">
                                        <span @click='handkeEditLink' v-loading.fullscreen.lock="loading">查看</span>
                                    </router-link>
                                    <span @click='DeleteActivityList(index)'>删除</span>
                                </div>
                            </div>
                        </div>
                    </el-tab-pane>
                    <el-tab-pane label='已发布' name='已发布'>
                        <div v-for='(item,index) in listInfo' :key='item.id' class="item-style">
                            <el-row>
                                <el-col :span="10">
                                    <div class="grid-content bg-purple base-topic">
                                        {{item.title}}
                                        <span class='introduce-info' v-if='item.recstatus == 0 ? false : true' >已推荐
                                        </span>
                                    </div>
                                </el-col>
                                <el-col :span="6">
                                    <div class="grid-content bg-purple-light base-topic">
                                        {{item.type == 1 ? '会员活动' : '普通活动'}}
                                    </div>
                                </el-col>
                                <el-col :span="6">
                                    <div class="grid-content bg-purple base-topic">
                                        更新日期：{{item.createDate}}
                                    </div>
                                </el-col>
                            </el-row>
                            <el-row>
                                <div class="grid-content bg-purple">
                                    <i class="iconfont icon-tubiao-"></i>
                                    <span>{{item.poitype == 1 ? '商户活动' : '商场活动'}}</span>
                                    <span>{{item.buildName}}</span>
                                </div>
                                <div class="grid-content bg-purple">
                                    <i class="iconfont icon-dizhi1"></i>
                                    {{item.place}} 
                                </div>
                                <div class="grid-content bg-purple">
                                    <i class="iconfont">&#xe624;</i>
                                    {{item.time}} 
                                    <span class="activity-time">{{item.enrollStart}} 到 {{item.enrollEnd}}</span>
                                    <span>活动时间:{{item.startDate}} 到 {{item.endDate}}</span>
                                </div>
                            </el-row>
                            <div class="advanced">
                                <div style="width:310px;">
                                    <span  
                                    class="close" 
                                    v-if='item.recstatus == 0 ? false : true' 
                                    @click='handleCloseIntroClick(index)'>
                                        解除推荐
                                    </span>
                                    <div v-if='item.recstatus == 0 ? true : false'>
                                        <span class="close" @click='handleIntroduce(index)'>推荐</span>
                                        <span 
                                        class="close"  
                                        :style="{ color: activeColor}" 
                                        @click='handleUpIntroClick(index)'>
                                            上移
                                        </span>
                                        <span class="close" @click='handleDownIntroClick(index)'>下移</span>
                                    </div>
                                </div>
                                <div style="flex:1;">
                                    <router-link :to="{path:'read_list/'+item.id,query:{title:item.title}}">
                                        <span class="read-num">
                                            <i class="iconfont">&#xe609;</i>
                                            {{item.readnum}}
                                        </span>
                                    </router-link>
                                     <router-link :to="{path:'good_list/'+item.id,query:{title:item.title}}">
                                     <span class="read-num">
                                        <i class="iconfont">&#xe60c;</i>
                                        {{item.goodnum}}
                                    </span>  
                                     </router-link>
                                </div>
                                <div class="activity-process">
                                    <router-link 
                                    :to="{path:'registration_list/'+item.id,query:{title:item.title}}">
                                        <span 
                                        v-show='item.enrollStatus==1 ? true : false' 
                                        @click='getActivity(index)' 
                                        v-loading.fullscreen.lock="loading">
                                            报名管理
                                        </span>
                                    </router-link>
                                    <router-link :to="'order_manage/'+item.id">
                                        <span 
                                        v-show='item.enrollStatus==1 ? true : false' 
                                        @click='handkeEditLink' 
                                        v-loading.fullscreen.lock="loading">
                                            订单管理
                                        </span>
                                    </router-link>
                                    <router-link :to="{path:'comment_list/'+item.id}">
                                        <span  
                                        @click='getActivityTitle(index)' 
                                        v-loading.fullscreen.lock="loading">
                                            评论管理
                                        </span>
                                    </router-link>
                                    <router-link :to="'mod/'+item.id">
                                        <span 
                                        @click='handkeEditLink' 
                                        v-loading.fullscreen.lock="loading">编辑</span>
                                    </router-link>
                                    <router-link :to="'view/'+item.id">
                                        <span 
                                        @click='handkeEditLink' 
                                        v-loading.fullscreen.lock="loading">查看</span>
                                    </router-link>
                                    <span 
                                    @click='handleClosePublish(index)' 
                                    v-show='item.status == 0 ? false : true'>下线
                                    </span>
                                    <span @click='handleActivityPass(index)'>核销</span>
                                </div>
                            </div>
                        </div>
                    </el-tab-pane>
                    <el-tab-pane label='已结束' name='已结束'>
                        <div v-for='(item,index) in listInfo' :key='item.id' class="item-style">
                            <el-row>
                                <el-col :span="10">
                                    <div class="grid-content bg-purple base-topic">
                                        {{item.title}}
                                    </div>
                                </el-col>
                                <el-col :span="6">
                                    <div class="grid-content bg-purple-light base-topic">
                                        {{item.type == 1 ? '会员活动' : '普通活动'}}
                                    </div>
                                </el-col>
                                <el-col :span="6">
                                    <div class="grid-content bg-purple base-topic">
                                        更新日期:{{item.createDate}}
                                    </div>
                                </el-col>
                            </el-row>
                            <el-row>
                                <div class="grid-content bg-purple">
                                    <i class="iconfont icon-tubiao-"></i>
                                    <span>{{item.poitype == 1 ? '商户活动':'商场活动' }}</span>
                                    <span>{{item.buildName}}</span>
                                </div>
                                <div class="grid-content bg-purple">
                                    <i class="iconfont icon-dizhi1"></i>
                                    {{item.place}} 
                                </div>
                                <div class="grid-content bg-purple">
                                    <i class="iconfont">&#xe624;</i>
                                    {{item.time}} 
                                    <span class="activity-time">{{item.enrollStart}} 到 {{item.enrollEnd}}</span>
                                    <span>活动时间: {{item.startDate}} 到 {{item.endDate}}</span>
                                </div>
                            </el-row>
                            <div class="advanced">
                                <div style="flex:1;text-align:center">
                                    <router-link :to="{path:'read_list/'+item.id,query:{title:item.title}}">
                                        <span class="read-num">
                                            <i class="iconfont">&#xe609;</i>
                                            {{item.readnum}}
                                        </span>
                                    </router-link>
                                     <router-link :to="{path:'good_list/'+item.id,query:{title:item.title}}">
                                     <span class="read-num">
                                        <i class="iconfont">&#xe60c;</i>
                                        {{item.goodnum}}
                                    </span>  
                                     </router-link>
                                </div>
                                <div class="activity-process">
                                    <router-link :to="{path:'registration_list/'+item.id,query:{title:item.title}}">
                                        <span 
                                        v-show='item.enrollStatus==1 ? true : false' 
                                        @click='getActivity(index)' 
                                        v-loading.fullscreen.lock="loading">报名管理
                                        </span>
                                    </router-link>
                                        
                                    <router-link :to="'order_manage/'+item.id">
                                        <span 
                                        v-show='item.enrollStatus==1 ? true : false' 
                                        @click='handkeEditLink' 
                                        v-loading.fullscreen.lock="loading">订单管理
                                        </span>
                                    </router-link>
                                    <router-link :to="{path:'comment_list/'+item.id}">
                                        <span 
                                        @click='getActivityTitle(index)' 
                                        v-loading.fullscreen.lock="loading">评论管理
                                        </span>
                                    </router-link>
                                    <router-link :to="'view/'+item.id">
                                        <span 
                                        @click='handkeEditLink' 
                                        v-loading.fullscreen.lock="loading">查看
                                        </span>
                                    </router-link>
                                    <router-link :to="'copy/'+item.id">
                                        <span>复制</span>
                                    </router-link>
                                    <span 
                                    @click='handleCloseEndPublish(index)' 
                                    v-show='item.status == 0 ? false : true'>下线
                                    </span>
                                </div>
                            </div>
                        </div>
                    </el-tab-pane>
                    <div class="block page-pagination">
                        <el-pagination
                            :current-page="currentPage"
                            :page-sizes="pageSizes"
                            :page-size="pageSize"
                            @size-change='getPageSizes'
                            @current-change="handleCurrentChange"
                            layout="total, sizes, prev, pager, next"
                            :total="count">
                        </el-pagination>
                    </div>
                </el-tabs>
            </div>
        </div>
        <div>
            <div class="img-view" @click="bigImg">
                <div v-show='isShowModal' @click='closeModal' class="layer">
                  <div class="qart">
                    <div id="code"></div>
                  </div>
                </div>
            </div>
        </div>
   <!-- //活动链接弹出层 <modal :activityLink='activityLink' v-show='activityLinkBtn' @clickit='hiddenModal'></modal> -->
       <transition name="fade">
            <div class="img-view" @touchmove.prevent v-show='activityLinkBtn'>
                <div class="img-layer">
                    <p class="content">
                        <span class="title">活动核销:</span>
                        <span id='activity-code' style="text-align:center;"></span>
                        <el-button type='info' class='confirm' @click='hiddenModal'>确定</el-button>
                    </p>
                </div>
            </div>
        </transition>
    </div>
</template>

<script>
import QArt from 'qartjs'
import modal from './modal'
  export default {
    data (){
      return {
        listInfo:'',
        currentPage:1,
        pageSizes:[10,15,20],
        pageNum:1,
        loading:false,
        pageSize:10,
        activityLinkBtn:false,
        activeName:'未发布',
        oneLoading:true,
        activityLink:'',
        activityLoading:false,
        status:0,
        rednum:'1',
        lovenum:'1',
        activeColor:'#569efe',
        count:null,
        publish:[],
        poilist:[],
        isShowIntroduce:false,
        value1:'',
        codeRootUrl:process.env.CodeRootUrl,
        downloadButton: true,
        buildList:[],
        buildId:null,
        poitype: '',
        type: '',
        isShowModal:false,
        building:'',
        createDateStart:'',
        createDateEnd:''
      }
    },

    components:{
      modal
    },

    methods:{
        handleSelectedTab(tab,event){
            if (event.target.innerHTML == '已发布') {
                this.status = 1
            }else if(event.target.innerHTML == '已结束'){
                this.status = 2
            }else if(event.target.innerHTML == '未发布'){
                this.status = 0
            } 
            window.sessionStorage.tabType = this.activeName
            this.getActivityData()
        },

        hiddenModal(){
            this.activityLinkBtn = false
        },

        handkeEditLink(){
            this.loading = true;
        },

        handleLink(){
            this.loading = true
            this.$router.push('add')
        },

        handleUpIntroClick(index){
            let Arr = []
            for (let i = 0; i < this.listInfo.length; i++) {
                if(this.listInfo[i].recstatus!=0){
                    Arr.push(this.listInfo[i])
                }
            }
            let len = Arr.length
            if(index-len > 0){
                this.$http.post('marketweb/actionback/snAction',{
                up_id:this.listInfo[index].id,
                keyAdmin:this.$store.state.keyAdmin,
                down_id:this.listInfo[index-1].id 
            }).then(response=>{
                if(response.body.code == '200'){
                    this.$message({
                        message: '上移成功',
                        type: 'success'
                    });
                }
                this.getActivityData()
                },response=>{
                    this.$message.error('上移失败')
                })
            }else{
            this.$message('不能进行上移')
            }
        },

        getActivityTitle(index){
            this.loading = true;
        },

        getActivity(index){
            this.loading = true;
        },

        handleDownIntroClick(index){
            if(index < this.listInfo.length-1){
                this.$http.post('marketweb/actionback/snAction',{
                    up_id:this.listInfo[index+1].id,
                    keyAdmin:this.$store.state.keyAdmin,
                    down_id:this.listInfo[index].id 
                }).then(response=>{
                    if(response.body.code == '200'){
                        this.$message({
                            message: '下移成功',
                            type: 'success'
                        });
                        this.getActivityData()
                    } 
                },response=>{
                  this.$message.error('下移失败')
                })
            }else{
              this.$message('不能进行下移')
            }
        },

        handleIntroduce(index){
            for (var i = 0; i < this.listInfo.length; i++) {
                if(this.listInfo[i].recstatus == 1){
                    this.publish.push(this.listInfo[i])
                }
            }
            if(this.publish.length<5){
                this.$confirm('确定将该活动推荐（置顶）？', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'info'
                }).then(() => {
                    this.listInfo[index].recstatus = 1
                    this.$http.post('marketweb/actionback/recstatusAction',{
                        actionId:this.listInfo[index].id,
                        keyAdmin:this.$store.state.keyAdmin,
                        recstatus:this.listInfo[index].recstatus 
                    }).then(response=>{
                        if(response.body.code == '200'){
                            this.$message({
                                message: '推荐成功',
                                type: 'success'
                            });
                            this.getActivityData()
                        }
                    },response=>{
                        this.$message.error('推荐失败')
                    })
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消操作'
                    });          
                });
            }else{
              this.$message.error('当前已有推荐活动已达上限（5个），请先解除，再将该活动推荐（置顶）')
            }
        
            this.publish=[]
        },

        DeleteActivityList(index){
            this.actionId = this.listInfo[index].id
            this.$confirm('此操作将删除该活动, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.$http.post('marketweb/actionback/deleteAction',{
                    keyAdmin:this.$store.state.keyAdmin,
                    actionId:this.actionId
                }).then(response=>{
                    if(response.body.code == 200){
                        this.$message({
                            message:'删除成功',
                            type:'success'
                        })
                        this.listInfo.splice(index,1)
                        this.count--
                    }else{
                        this.$message.error(response.body.msg)
                    }
                },response=>{
                    this.$message.error('请求操作失败')
                })
            }).catch(() => {
                this.$message({
                    type: 'info',
                    message: '已取消删除'
                })       
            })
        },

        handleCloseIntroClick(index){
            this.$confirm('确定要对该活动解除推荐?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'info'
            }).then(() => {
               this.listInfo[index].recstatus = 0;
               this.$http.post('marketweb/actionback/recstatusAction',{
                    actionId:this.listInfo[index].id,
                    keyAdmin:this.$store.state.keyAdmin,
                    recstatus:this.listInfo[index].recstatus 
                }).then(response=>{
                    if (response.body.code == '200') {
                        for (var i = 0; i < this.listInfo.length; i++) {
                            if(this.listInfo[i].recstatus == 0){
                                this.publish.splice(i,1)
                            }
                        }
                        this.$message({
                          message: '解除推荐成功',
                          type: 'success'
                        });
                        this.getActivityData()
                    }
                },response=>{
                  this.$message.error('解除推荐失败')
                })
            }).catch(() => {
                this.$message({
                    type: 'info',
                    message: '已取消操作'
                })          
            })
        },

        handlePublish(index){
            this.$confirm('将此活动上线, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'info'
            }).then(() => {
                this.listInfo[index].status = 1
                this.status = 0
                this.$http.post('marketweb/actionback/statusAction',{
                    actionId:this.listInfo[index].id,
                    keyAdmin:this.$store.state.keyAdmin,
                    status:this.listInfo[index].status 
                }).then(response=>{
                    if(response.body.code == '200'){
                        this.$message({
                            message: '上线成功',
                            type: 'success'
                        });
                       this.getActivityData()
                    }
                },response=>{
                    this.$message.error('发布上线失败')
                })
            }).catch(() => {
                this.$message({
                    type: 'info',
                    message: '已取消操作'
                })         
            })
        },

        handleCloseEndPublish(index){
            this.$confirm('将此活动下线, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'info'
            }).then(() => {
                this.listInfo[index].status = 0
                this.status = 2
                this.$http.post('marketweb/actionback/statusAction',{
                    actionId:this.listInfo[index].id,
                    keyAdmin:this.$store.state.keyAdmin,
                    status:this.listInfo[index].status 
                }).then(response=>{
                    if(response.body.code == '200'){
                        this.$message({
                            message: '下线成功',
                            type: 'success'
                        });
                        this.getActivityData()
                    }
                },response=>{
                    this.$message.error('下线失败')
                })
            }).catch(() => {
                this.$message({
                    type: 'info',
                    message: '已取消操作'
                });          
            });
        },

        handleClosePublish(index){
            this.$confirm('将此活动下线, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'info'
            }).then(() => {
                this.listInfo[index].status = 0
                this.status = 1
                this.$http.post('marketweb/actionback/statusAction',{
                    actionId:this.listInfo[index].id,
                    keyAdmin:this.$store.state.keyAdmin,
                    status:this.listInfo[index].status 
                }).then(response=>{
                    if(response.body.code == '200'){
                        this.$message({
                            message: '下线成功',
                            type: 'success'
                        });
                        this.getActivityData()
                    }
                },response=>{
                  this.$message.error('下线失败')
                })
            }).catch(() => {
                this.$message({
                    type: 'info',
                    message: '已取消操作'
                })         
            })
        },

        handleModalLink(index){
            let keyAdmin = this.$store.state.keyAdmin
            let activityId = this.listInfo[index].id
            this.activityLink = 'https://mem.rtmap.com/Thirdwechat/Wechat/Oauth/getuserinfo?jumpurl='+encodeURIComponent('https://h5.rtmap.com/actcustom/details?key_admin='+keyAdmin+'&id='+activityId)+'&key_admin='+keyAdmin+'&scope=snsapi_userinfo'
            this.activityLinkBtn = true;
        },

        handleCheckList(){
            this.getActivityData()
        },

        getPageSizes(size){
            this.pageSize = size;
            this.getActivityData()
        },

        handleCurrentChange(val){
            this.pageNum = val;
            this.getActivityData()
        },

        getActivityData(){
            this.$http.post(
            'marketweb/actionback/queryActions',{
                keyAdmin:this.$store.state.keyAdmin,
                pageNum:this.pageNum,
                pageSize:this.pageSize,
                status:this.status,
                buildId:this.buildId,
                createDateStart:this.createDateStart,
                createDateEnd:this.createDateEnd,
                type:this.type,
                poitype:this.poitype
            }).then(response => {
                if (response.body.code == 200) {
                    this.listInfo = response.body.actionlist;
                    this.count = response.body.count;
                    this.oneLoading = false;
                }else{
                    this.$message.error(response.body.msg)
                }
           
            }, response => {
                this.$message.error("加载活动列表失败");
            });
        },

        getStartTime(val){
            this.createDateStart = val
        },

        qrcode () {
            const qart = new QArt({
                value: this.codeRootUrl +this.$store.state.keyAdmin,
                imagePath: '',
                filter: 'color',
                size: 195
            });
            qart.make(document.getElementById('code'));
        },

        handleActivityPass(index){
            this.activityLinkBtn = true;
            let activityQart = new QArt({
                value: this.codeRootUrl +this.$store.state.keyAdmin +'?id=' + this.listInfo[index].id,
                imagePath: '',
                filter: 'color',
                size: 195
            });
            activityQart.make(document.getElementById('activity-code'))
        },

        bigImg(){
            this.isShowModal = false;
        },

        getEndTime(val){
            this.createDateEnd = val
        },

        handlePassList(){
            this.isShowModal=true
        },
        closeModal(){
            this.isShowModal =false
        },

        getbuildId(val){
            this.buildId = val
        },

        getType(val){
            this.type = val
        },


        getPoitype(val){
            this.poitype = val
        },

        handleClearList(){
            this.poitype = '',
            this.type = '',
            this.createDateStart = '',
            this.createDateEnd = ''
        },

        getBuildingData(){
            this.$http.post('marketweb/build/querybuilds',{
                keyAdmin:this.$store.state.keyAdmin
            }).then(response => {
                if(response.body.code == 200){
                    this.buildList = response.body.buildList
                    this.building = this.buildList[0].buildIdStr
                    this.buildId = this.building
                    this.getActivityData();
                }else{
                    this.$message.error(response.body.msg)
                }
            }, response => {
              this.$message.error("获取分类列表数据失败");
            })
        }
    },

    mounted(){
       this.qrcode();
    },

    beforeRouteEnter(to,from,next){
        next(vm=>{
            if(from.name=='ActivityEdit'||from.name=='RegistrationList'||from.name=='ActivityGood'||from.name=='ReadList'||from.name=='ActivityView'||from.name=='CommentList'||from.name=='OrderManage'||from.name=='ActivityCopy'||from.name=='RegistrationManagement' || from.name=='CheckOrder'||from.name=='CommentCheck'){
                    vm.activeName = window.sessionStorage.tabType?window.sessionStorage.tabType:'未发布'
                if (vm.activeName == '已发布') {
                    vm.status = 1
                }else if(vm.activeName == '已结束'){
                    vm.status = 2
                }else if(vm.activeName == '未发布'){
                    vm.status = 0
                } 

                vm.getActivityData();
            }else{
              window.sessionStorage.removeItem('tabType')
            }
        })
    },
    
    created(){
      this.getBuildingData();
    },

    beforeRouteLeave(to,from,next){
        next(vm=>{
            vm.loading = false
        })
    }
  }
</script>

<style scoped>
@import "../../../../assets/base/font/iconfont.css";
	.main-title{
		margin:0 5px;
		font-size: 18px;
        color: #569efe;
	}
  .main{
    width: 100%;
  }
  .main-page{
    width: 100%;
  }
  .pass-btn{
    padding: 8px 10px;
  }
  .check-created{
    padding:10px;
    margin:3px;
  }
  .fade-enter-active, .fade-leave-active {
     transition: opacity .5s
  }
  .fade-enter,
  .fade-leave-active {
       opacity: 0
  }
  .img-view {
      position: relative;
      width: 100%;
      height: 100%;
  }
  .layer {
      border-radius: 10px;
      width: 240px;
      height: 240px;
      position: fixed;
      z-index: 2;
      left: 40px;
      margin-top: 120px;
      bottom: 0px;
  }
  .img-info{
      display: block;
      width:300px;
      height:300px;
      position: absolute;
      left: 50%;
      top: 50%;
      margin-top:-150px;
      margin-left:-150px;
      z-index: 1000;
  }
  .main-info{
    display: flex;
    justify-content: space-between;
    padding: 0 10px;
    border-bottom:2px solid #569efe;
    padding-bottom: 5px;
  }
  .el-button--primary{
    padding: 8px 12px;
   
  }
  .el-button-danger{
    padding: 8px 12px;
    position: absolute;
    right: 20px;
    bottom:10px;
  }
  .activity-release{
    font-size: 12px;
    color: #666666
  }
  .select-condition{
    background: #eee;
    position:relative;
    margin:10px 0;
    padding:5px;
  }
  .el-select{
    width:180px;
    font-size: 14px;
  }
  .el-select-dropdown{
    color: #333;
  }
  .block{
    display: inline-block;
  }
  .activity-release{
    width:100px;
  }

  .el-tabs__header{
    background: #eee;
  }
  .el-tabs{
    margin-top: 15px;
  }
  .check-btn{
    padding: 8px 10px;
  }
  .introduce-info{
    margin-left: 10px;
    padding: 2px 4px;
    color: #333;
    border: 1px solid #4fabe7
  }
  .list-data{
    position: relative;
  }
  .check-activity-btn{
    position: absolute;
    right: 20px;
    bottom: 8px;
  }
  .base-topic{
    font-size: 12px;
    color: #020202;
    line-height: 20px;
  }
  .item-style{
    background: #eee;
    margin:10px 0;
    font-size: 12px;
    color: #020909;
    padding:10px;
  }
  .edit{
    position: absolute;
    top:6px;
    right: 15px;
    z-index: 2;
  }
  .check-activity-list{
    padding: 4px 8px;
  }
  .activity-process{
    text-align: right;
  }
  .read-num{
      color: #666;
      font-size: 14px;
      padding: 0 20px;
      cursor: pointer;
  }
   .read-num:hover{
        color: #4fabe7;
   }
  .activity-process span{
      padding: 0 5px;
      color: #666;
      cursor: pointer;
    }
  .activity-time{
    margin-right:40px;
  }
  .activity-process span:hover{
    color: #4fabe7;
    text-decoration: underline;

  }
  .grid-content{
    line-height: 1.5;
  }
  .page-pagination{
    float: right;
    min-width: 380px;
    margin: 20px auto;
  }
  .close{
    color: #569efe;
    text-decoration: underline;
    cursor: pointer;
  }
  .el-form-item{
    margin-bottom: 5px;
  }
  .close:hover{
    color: #666;
  }
  .advanced{
    display: flex;
    padding-bottom: 8px;
    padding-top: 10px;
  }
  .fade-enter-active,
.fade-leave-active {
     transition: opacity .5s
}
.fade-enter,
.fade-leave-active {
     opacity: 0
}
.img-view {
    position: relative;
    width: 100%;
    height: 100%;
}
.img-layer {
    width: 100%;
    height: 100%;
    position: fixed;
    z-index: 999;
    top: 0;
    left: 0;
    background: rgba(0, 0, 0, 0.5);
}
.title{
    color: #569efe;
    border-bottom: 1px dashed #ccc;
    padding-bottom: 5px;
    text-align: left;
    display: inline-block;
    width: 100%;
    margin-bottom: 15px;
    font-size: 18px;
}
.content{
    width:360px;
    height:260px;
    text-align: center;
    border: 1px solid #000;
    border-radius: 10px;
    background: #fff;
    color: #666;
    position: absolute;
    padding: 20px;
    left:50%;
    top: 50%;
    line-height: 1.1;
    box-shadow: 0 0 3px #ccc;
    word-wrap:break-word;
    margin-left: -180px;
    margin-top: -130px;
    z-index: 999;
}
.confirm{
    position: absolute;
    z-index: 1000;
    right: 20px;
    bottom: 20px;
}
</style>